//
//  MXFindContentCollectionViewCell.m
//  MXの衣柜
//
//  Created by 马霄 on 15/8/6.
//  Copyright (c) 2015年 霄 马. All rights reserved.
//

#import "MXFindContentCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface MXFindContentCollectionViewCell ()
@property (nonatomic, retain) UILabel *priceLabel;
@end

@implementation MXFindContentCollectionViewCell
- (void)dealloc
{
    [_priceLabel release];
    [_modelS release];
    [_mainImageView release];
    [_detailLabel release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.mainImageView = [[[UIImageView alloc] init] autorelease];
        self.mainImageView.backgroundColor = [UIColor clearColor];
        self.mainImageView.layer.cornerRadius = 30;
        self.mainImageView.layer.masksToBounds = YES;
        [self.contentView addSubview:self.mainImageView];
        
        self.detailLabel = [[[UILabel alloc] init] autorelease];
        self.detailLabel.backgroundColor = [UIColor clearColor];
        self.detailLabel.numberOfLines = 2;
        self.detailLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.detailLabel];
        
        self.priceLabel = [[[UILabel alloc] init] autorelease];
        self.priceLabel.backgroundColor = [UIColor grayColor];
        [self.mainImageView addSubview:self.priceLabel];
        
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat WID = self.frame.size.width;
    self.mainImageView.frame = CGRectMake(0, 0, WID, WID);
    
    self.detailLabel.frame = CGRectMake(0, WID, WID, HEIGHTPRO * 40);
}
-(void)getInfo:(MXFindModel *)model
{
    if (_modelS != model) {
        [_modelS release];
        _modelS = [model retain];
    }
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:@"plaseholder"]];
    
    self.detailLabel.text = model.title;
}

-(void)setModelS:(MXFindModel *)modelS
{
    if (_modelS != modelS) {
        [_modelS release];
        _modelS = [modelS retain];
    }
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:modelS.img] placeholderImage:[UIImage imageNamed:@"plaseholder"]];
    
    self.detailLabel.text = modelS.title;

}

-(void)getItemInfo:(MXDataBaseItemModel *)DBModel
{
    
    
    self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.mainImageView.frame.size.height - WIDTHPRO * 30, self.mainImageView.frame.size.width, HEIGHTPRO * 30)];
    self.priceLabel.backgroundColor = [UIColor grayColor];
    self.priceLabel.alpha = 0.75;
    self.priceLabel.text = DBModel.price;
    [self.priceLabel setTextColor:[UIColor blackColor]];
    
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:DBModel.imagePath]];
    
    self.detailLabel.text = DBModel.detail;
    
    
}

@end
